#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve() {
    ll n;
    cin >> n;
    vector<ll> cnt(n + 1);
    map<ll, ll> mp;
    ll x, ans = 0;
    for(int i = 0; i < n; i++) cin >> x, mp[x]++;
    for(auto [k, v] : mp) {
        x = k;
        ll b = x;
        while(x <= n) {
            cnt[x] += v;
            x += b;
            ans = max(ans, cnt[x - b]);
        }
    }
    cout << ans << endl;
}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}